package com.qf.ssm.controller;

import com.github.pagehelper.PageInfo;
import com.qf.ssm.result.ResponseResult;
import com.qf.ssm.service.CustomerOrderService;
import com.qf.ssm.vo.CustomerOrderVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chengqiang
 * @Create 2024-01-03-21:32
 * @Description: 租赁记录
 */
@RestController
@RequestMapping(("/customer/order"))
@Api(tags = "客户的租赁记录")
public class CustomerOrderController {
    @Autowired
    private CustomerOrderService customerOrderService;


    @GetMapping(value = {"/list/{pageNum}/{pageSize}","/list"})
    @ResponseBody
    @ApiOperation("查询租赁记录")
    @ApiImplicitParams({@ApiImplicitParam(name = "pageNum", value = "页码"),@ApiImplicitParam(name = "pageSize", value = "条数"),@ApiImplicitParam(name = "id", value = "客户id")})
    @ApiResponses({@ApiResponse(code = 2000, message = "成功", response = CustomerOrderVO.class), @ApiResponse(code = 40008, message = "未知错误")})
    public ResponseResult<PageInfo<CustomerOrderVO>> listCustomerOrderByCid(@RequestParam("id") Integer id,@PathVariable(required = false) Integer pageNum, @PathVariable(required = false) Integer pageSize){
        if(pageNum==null){
            pageNum=1;
        }
        if(pageSize==null){
            pageSize=3;
        }
        System.out.println(id);
        return ResponseResult.success(customerOrderService.queryCustomerOrderByCid(pageNum, pageSize, id));
    }
}
